home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / grafic.h < prev    next >
C/C++ Source or Header  |  1994-11-11  |  2KB  |  72 lines

  1. // Class for drawing of axes and data sets (up to 15)
  2.  
  3. #ifndef __GRAFIC_H_
  4. #define __GRAFIC_H_
  5.  
  6. #include "axes2.h"
  7. #include "graf.h"
  8.  
  9. /*  This structure incapsulate dataset with its screen attributes.
  10.     It also could be saved to disk and loaded back to memory
  11.     when necessary (this option is not automatic, and only data are
  12.     saved, not attributes, as colors and so on).
  13. */
  14.  
  15. struct GrafData
  16.     {
  17.     Graf* graf;         // marker_type; line_type; attr; bak; size; fill;
  18.     int* data_x;        // Array of X coordinates
  19.     int* data_y;        // Array of Y coordinates
  20.     int num_points;     // Total number of data X-Y pares
  21.     char* fileName;     // Name of file to swap data
  22.  
  23.     GrafData(char attr_color, char back_color, int marker_type,
  24.          int line_type, int size_of_marker, int fill_style,
  25.          int* data_x, int* data_y, int num_points, char* fName = "");
  26.     ~GrafData();
  27.     void load();
  28.     void save();
  29.     };
  30.  
  31. /*  Class Grafic draws axes, grid and curves. It could load double
  32.     arrays and keep them as recalculated int arrays (in GrafData
  33.     structures).
  34. */
  35.  
  36. class Grafic : public Axes2
  37.     {
  38.     protected:
  39.     int used;                    // Number of lines, 1 - 15
  40.     rect coord;                  // Rectangle, including labels
  41.     rect work_coord;             // Rectangle, not including labels
  42.  
  43.     int ax_col; int lab_col;     // Axes and labels colors
  44.     loc zero;
  45.     double zero_x;
  46.     double zero_y;
  47.     double len_x;
  48.     double len_y;
  49.     int grid_style;
  50.     public:
  51.     GrafData* arrays[15];
  52.  
  53.     Grafic(rect r, int ax, int lab, int g = 5, int save = 0);
  54.     
  55.     ~Grafic();
  56.  
  57.     rect get_work_coord() { return work_coord; }
  58.     loc get_colors() { return loc(ax_col, lab_col); }
  59.     void grid();
  60.     loc get_zero(double xmin, double ymin, double xmax, double ymax);
  61.     int bar_width();
  62.     void get_x_array(int ar, int num, double* data);
  63.     void get_y_array(int ar, int num, double* data);
  64.     rect set_work_rect(rect r) { return work_coord = r; }
  65.     void set_rect(rect r) { coord = r; }
  66.     void redraw();
  67.     void show_axes();
  68.     int* get_stacked(int n);
  69.  
  70.     };
  71.  
  72. #endif __GRAFIC_H_